# Appveyor project configuration file
# Build the plugin on Windows environment

version: 0.8.3.{build}

# Official QtC binaries are built
# with msvc2015-x86
os: Visual Studio 2015

environment:
  QTDIR: C:\Qt\5.11\msvc2015
  VSVER: 14.0
  BINTRAY_KEY:
    secure: 64COF2Ng3AdKqw6BEQqhlTu8G1j0F43qv6zZ6tg4VLbVCxXBxB2kW42COoqSiBJA
  matrix:    
    - platform: x86
      QTC_VER: 4.5
      VS_VER: 2015
    
    - platform: x64
      QTC_VER: 4.5
      VS_VER: 2015
    
    - platform: x86
      QTC_VER: 4.6
      VS_VER: 2015
    
    - platform: x64
      QTC_VER: 4.6
      VS_VER: 2015
    
    - platform: x86
      QTC_VER: 4.7
      VS_VER: 2015
    
    - platform: x64
      QTC_VER: 4.7
      VS_VER: 2015
    
    - platform: x86
      QTC_VER: 4.8
      VS_VER: 2015
    
    - platform: x64
      QTC_VER: 4.8
      VS_VER: 2015
    
    - platform: x86
      QTC_VER: 4.9
      VS_VER: 2017
    
    - platform: x64
      QTC_VER: 4.9
      VS_VER: 2017
    
    - platform: x86
      QTC_VER: 4.10
      VS_VER: 2017
    
    - platform: x64
      QTC_VER: 4.10
      VS_VER: 2017

    - platform: x86
      QTC_VER: 4.11
      VS_VER: 2017

    - platform: x64
      QTC_VER: 4.11
      VS_VER: 2017
      
    - platform: x86
      QTC_VER: 4.12
      VS_VER: 2017
      
    - platform: x64
      QTC_VER: 4.12
      VS_VER: 2017

configuration:
  - Release

# Download and unpack QtC sources and binaries
install:
  - cmd: IF %VS_VER% == 2015 IF %PLATFORM% == x86 SET download_dir=windows_vs%VS_VER%_32
  - cmd: IF %VS_VER% == 2015 IF %PLATFORM% == x64 SET download_dir=windows_vs%VS_VER%_64
  - cmd: IF %VS_VER% == 2017 SET download_dir=windows_msvc%VS_VER%_%PLATFORM%  
  - cmd: echo %download_dir%
  - cmd: curl -fsSL "http://download.qt.io/official_releases/qtcreator/%QTC_VER%/%QTC_VER%.0/installer_source/%download_dir%/qtcreator_dev.7z" -o %APPVEYOR_BUILD_FOLDER%\qt-dev.7z
  - cmd: 7z x -y qt-dev.7z -o"%APPVEYOR_BUILD_FOLDER%\qt-src\" | findstr /b /r /c:"\<Everything is Ok"
  - cmd: curl -fsSL "http://download.qt.io/official_releases/qtcreator/%QTC_VER%/%QTC_VER%.0/installer_source/%download_dir%/qtcreator.7z" -o %APPVEYOR_BUILD_FOLDER%\qt-bin.7z
  - cmd: 7z x -y qt-bin.7z -o"%APPVEYOR_BUILD_FOLDER%\qt-bin\" | findstr /b /r /c:"\<Everything is Ok"

# Setup an environment and generate import libs
before_build:
  - cmd: echo %QTDIR%
  - cmd: IF %PLATFORM% == x64 set QTDIR=%QTDIR%_64
  - cmd: echo %QTDIR%
  - cmd: '%QTDIR%\bin\qtenv2.bat'
  - cmd: '"%ProgramFiles(x86)%\Microsoft Visual Studio %VSVER%\VC\vcvarsall.bat" %PLATFORM%'
  - cmd: mkdir %APPVEYOR_BUILD_FOLDER%\qt-libs

build_script:
  - cmd: qmake %APPVEYOR_BUILD_FOLDER%/qtc-sourcetrail.pro -r "QTC_SOURCE=%APPVEYOR_BUILD_FOLDER%\qt-src" "QTC_BUILD=%APPVEYOR_BUILD_FOLDER%\qt-bin\bin" "LIBS+=-L%APPVEYOR_BUILD_FOLDER%\qt-libs" "OUTPUT_PATH=%APPVEYOR_BUILD_FOLDER%\output"
  - cmd: nmake.exe

after_build:
  - cmd: 7z a %APPVEYOR_BUILD_FOLDER%\qtc-sourcetrail-windows-%PLATFORM%-qtc%QTC_VER%.zip %APPVEYOR_BUILD_FOLDER%\output\*

artifacts:
  - path: 'qtc-sourcetrail-windows-%PLATFORM%-qtc%QTC_VER%.zip'
    name: '%APPVEYOR_PROJECT_NAME%'

deploy:
  #release: qtc-sourcetrail-windows_v$(appveyor_repo_tag_name)
  description: 'Qt Creator plugin for communication with Sourcetrail'
  provider: GitHub
  auth_token:
    secure: jyuVA4RE9Rj3azDEXi2jdsZZHYMMkAmajahaeEEVUA/hPAXl82zdUQoEcPH+Y9me
  on:
    appveyor_repo_tag: true
